package number

// https://leetcode-cn.com/leetbook/read/top-interview-questions-easy/xnc5vg/
// 输出 无符号整数 按二进制表示之后，反向之后的结果
func reverseBits(num uint32) (ret uint32) {
	var currentBit uint32 = 1 << 31
	var currentBase uint32 = 1
	for currentBit != 0 {
		if 0 != currentBit&num {
			ret += currentBase
		}
		currentBit >>= 1
		currentBase <<= 1
	}
	return
}
